<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width;height=device-height;">
    <meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; user-scalable=no;">
    <title>收银台</title>
    <script src="/assets/vue.min.js"></script>
    <script src="/assets/vant.js"></script>
    <script src="/assets/utils.js"></script>
    <script src = "https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"> </script>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script>
        /**
         * 判断当前环境是否为支付宝内置浏览器
         * @returns {boolean} 是支付宝浏览器返回 true，否则返回 false
         */
        function isAlipayBrowser() {
            // 获取当前浏览器的 User Agent 字符串
            const ua = navigator.userAgent;

            // 检查 UA 中是否包含支付宝的特征标识
            // 常见的标识包括：AlipayClient, Alipay, AlipayDefined
            return /AlipayClient|Alipay|AlipayDefined/i.test(ua);
        }


        window.addEventListener('load', function() {
            if(isAlipayBrowser()){
                ap.getAuthCode ({
                    appId :  '2021005185660440' ,
                    scopes : ['auth_user'],
                },function(res){
                    // ap.alert (JSON.stringify(res));
                    // 1. 解析 JSON 字符串
                    const data = JSON.parse(JSON.stringify(res));
                    // 2. 获取 authcode 字段（注意是小写）
                    const authcodes = data.authcode;
                    // alert("authcodes=>"+authcodes);
                    postData(authcodes);
                });
            }   else {

            }

        });

        function postData(authcode) {
            $.ajax({
                url: "https://www.payxiao.com/payServer/payweb/getZfbUserId",
                data: JSON.stringify({ code: authcode }),
                type: "POST",
                dataType: "json",
                contentType: "application/json",
                success: function (data) {
                    const result = data;  //JSON.parse(JSON.stringify(data))
                    if (result && result.data && result.data.openId) {
                        const openId = result.data.openId;
                        document.getElementById('zfbUserId').value = openId;
                    }
                },
                error: function (text) {
                    console.log(text);
                }
            });
        }
    </script>
    <link href="/assets/vant.css" rel="stylesheet">
    <link href="/assets/cashier.css" rel="stylesheet">
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body class="van-overflow-hidden">
<div id="page" class="page">


    <div class="page-head">
        <span class="sp_r"><i class="van-icon van-icon-shop-o" style="color: rgb(255, 255, 255); font-size: 24px;"><!----></i></span>
        <div>
            <p class="p1">{{merName}}</p>
            <p class="p2"><span class="van-tag van-tag--plain van-tag--primary">门店</span><span
                class="s1">{{terName}}({{sn}})</span></p>
        </div>
    </div>
    <div class="page-amount">
        <div class="c6">
            金额
        </div>
        <div>
            <label class="amt-ft-l">￥</label>
            <label class="amt-ft">{{ amount }}</label>
        </div>
    </div>
    <div class="page-remark">
        <span v-if="remark" style="font-size: 16px">{{ remark }},</span>
        <a class="a-link" @click="() => showRemark = true">{{ remark ? '修改' : "备注"}}</a>
    </div>
    <div v-if="isShowKey">
        <van-number-keyboard :show="true"
                             theme="custom"
                             :extra-key="['00', '.']"
                             :close-button-text="begin==1?'支付中':'确定'"
                             @close="beginPay"
                             maxlength="9"
                             @delete="delNum"

                             @input="getNum"/>
    </div>

    <div class="btn-pay" v-else>
        <van-button type="primary" block color="#0094ff" @click="beginPay">支付</van-button>
    </div>


    <div>
        <van-popup v-model:show="showRemark">
            <div class="remark-title">备注</div>
            <div class="remark-tip">
                <van-field v-model="inputRemark"
                           clearable
                           maxlength="50" show-word-limit="true"
                           placeholder="请输入交易备注"/>
            </div>
            <div class="btn-floot">
                <a class="btn-cannel" @click="showRemark=false">取消</a>
                <a class="btn-confirm" @click="confirmRemark">确定</a>

            </div>
        </van-popup>
    </div>
    <span id="zfbUserId" hidden style="display:none;"></span>
</div>

<script src="/assets/cashier-1.js?v=7.2"></script>


<audio controls="controls" style="display: none;"></audio>
</body>
</html>
